import java.util.Scanner;
import java.util.Stack;
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str ;
        while(sc.hasNext()) {
            str = sc.next();
            System.out.println(str+" "+isValid(str));
        }
        // ()  ()[]{}  (]

        sc.close();
    }
    /* 请在这里填写答案 */
    public static boolean isValid(String s){
        Stack<String> st = new Stack<String>();
        String[] chars = s.split("");
        for (int i = 0; i < chars.length; i++) {
            if(chars[i].equals("[")||chars[i].equals("(")||chars[i].equals("{")){
                st.push(chars[i]);
            }else {
                if(st.empty()) {
                    return false;
                }
                if((chars[i].equals("]")&&st.peek().equals("["))
                        ||(chars[i].equals(")")&&st.peek().equals("("))
                        ||(chars[i].equals("}")&&st.peek().equals("{"))) {
                    st.pop();
                }else{
                    return false;
                }
            }
        }
        if(st.empty())
            return true;
        return false;
    }
}
